//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __GSENSOR_H__
#define __GSENSOR_H__

#include <driver.h>
#include <GSensor.h>


#define GSENSOR_DEVICE_NAME L"device:gsensor0"

enum {
    GSENSOR_NONE_INTERRUPT          = 0x0000,
    GSENSOR_OVERRUN_INTERRUPT       = 0x0001,
    GSENSOR_WATERMARK_INTERRUPT     = 0x0002,
    GSENSOR_FREEFALL_INTERRUPT      = 0x0004,
    GSENSOR_INACTIVITY_INTERRUPT    = 0x0008,
    GSENSOR_ACTIVITY_INTERRUPT      = 0x0010,
    GSENSOR_DOUBLE_TAP_INTERRUPT    = 0x0020,
    GSENSOR_SINGLE_TAP_INTERRUPT    = 0x0040,
    GSENSOR_DATA_READY_INTERRUPT    = 0x0080,

    GSENSOR_ROTATE_UP_INTERRUPT     = 0x0100,
    GSENSOR_ROTATE_DOWN_INTERRUPT   = 0x0200,
    GSENSOR_ROTATE_LEFT_INTERRUPT   = 0x0300,
    GSENSOR_ROTATE_RIGHT_INTERRUPT  = 0x0400,
    GSENSOR_ROTATE_TOP_INTERRUPT    = 0x0500,
    GSENSOR_ROTATE_BOTTOM_INTERRUPT = 0x0600,
    GSENSOR_ROTATE_ZERO_INTERRUPT   = 0x0700,
    GSENSOR_ROTATE_INTERRUPT        = 0x0F00,

    GSENSOR_SHAKE_INTERRUPT         = 0x4000,
    GSENSOR_REPEAT_INTERRUPT        = 0x8000,

    GSENSOR_SWITCH_INTERRUPT        = 0xFFFF
};

enum {
    GSENSOR_UP      = 0x0100,
    GSENSOR_DOWN    = 0x0200,
    GSENSOR_LEFT    = 0x0300,
    GSENSOR_RIGHT   = 0x0400,
    GSENSOR_TOP     = 0x0500,
    GSENSOR_BOTTOM  = 0x0600,
    GSENSOR_ZERO    = 0x0700
};

class CGSensor: public CDeviceDriver
{
public:
    CARAPI Read(
        /* [in] */  Int64 offset,
        /* [in] */  Int32 bytesToRead,
        /* [out] */ MemoryBuf * pBuffer,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Write(
        /* [in] */  Int64 offset,
        /* [in] */ const  MemoryBuf & buffer,
        /* [out] */ Int32 * pBytesWritten,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Control(
        /* [in] */  Handle32 constrolCode,
        /* [in] */ const  MemoryBuf & inBuffer,
        /* [out] */ MemoryBuf * pOutBuffer,
        /* [out] */ IEvent * * ppCompletionEvent);

    virtual void Dispose() {}

    CGSensor(){}
    ~CGSensor();
};

#endif
